package com.nervenets.shopping.controller.user.params;

import com.nervenets.general.exception.LogicException;
import com.nervenets.general.web.params.FormParams;
import com.nervenets.general.web.params.TreeFormParams;
import com.nervenets.shopping.enumeration.Gender;
import com.nervenets.shopping.hibernate.domain.user.User;
import com.nervenets.shopping.service.UserService;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.SuperBuilder;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@EqualsAndHashCode(callSuper = true)
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class UserFormParams extends TreeFormParams<User, UserService> {
    @ApiModelProperty(value = "账号", required = true)
    @NotBlank
    @Size(min = 5, max = 20)
    private String mobile;
    @ApiModelProperty(value = "密码", required = true)
    @NotBlank
    @Size(min = 6, max = 20)
    private String password;
    @ApiModelProperty(value = "头像")
    private String avatar;
    @ApiModelProperty(value = "性别")
    private Gender gender;
    @ApiModelProperty(value = "是否启用")
    private boolean enable;
    @ApiModelProperty(value = "省份")
    private String province;
    @ApiModelProperty(value = "城市")
    private String city;

    @Override
    public User validateAndBuild(UserService service, HttpServletRequest request, HttpServletResponse response) {
        throw new LogicException("该接口不提供直接添加客户账号");
    }
}
